<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ page import="com.library.dao.Librarian" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Cập nhật thông tin người dùng</title>
<%
Librarian user=(Librarian)session.getAttribute("instantUser");
%>
<script type="text/javascript">
function getinfor(){
	var id = document.getElementById("userid").value;
	if ((id != null) && (id != "")){
		var xmlhttp;
		var txt,x,xx,i;
		if (window.XMLHttpRequest)
		  {// code for IE7+, Firefox, Chrome, Opera, Safari
		  xmlhttp=new XMLHttpRequest();
		  }
		else
		  {// code for IE6, IE5
		  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		xmlhttp.onreadystatechange=function()
		  {
			 if ((xmlhttp.readyState==4) && (xmlhttp.status == 200)){
				 try{
					 x=xmlhttp.responseXML.documentElement.getElementsByTagName("user");
					 xx = x[0].getElementsByTagName("name");
					 document.getElementById("name").value = xx[0].firstChild.nodeValue;
					 
					 xx = x[0].getElementsByTagName("phone");
					 document.getElementById("phone").value = xx[0].firstChild.nodeValue;	
					 
					 xx = x[0].getElementsByTagName("email");
					 document.getElementById("email").value = xx[0].firstChild.nodeValue;	
					 
					 xx = x[0].getElementsByTagName("password");
					 document.getElementById("password").value = xx[0].firstChild.nodeValue;
					 
					 xx = x[0].getElementsByTagName("address");
					 document.getElementById("error").innerHTML = "";
					 document.getElementById("address").value = xx[0].firstChild.nodeValue;
				 } catch(err){
					 document.getElementById("error").innerHTML = "Nhập ID lỗi";
				 }
				 	
			 }
			
		  };
		
		var query = "?id="+id;
		xmlhttp.open("GET","/librarysystem/LibrarianGetInfor"+query,true);
		xmlhttp.send();	
	}
}
</script>

</head>
<body>
<jsp:include page="librarianmenu.jsp" /> 
<br>
<br>
<p id ="error"> </p>
<form id="form1" name="form1" method="post" action="/librarysystem/LibrarianUpdateUserInfo">

  <table width="70%" border="0">
  <tr>
      <td width="93" height="31">UserId</td>
      <td width="200"><input name="userid" type="text" id="userid" size="50" onBlur="getinfor()"/></td>
    </tr>
    <tr>
      <td width="93" height="31">Email</td>
      <td width="200"><input name="email" type="text" id="email" size="50"  /></td>
    </tr>
    <tr>
      <td>Mật khẩu</td>
      <td><label>
        <input name="password" type="password" id="password" size="30" />
      </label></td>
    </tr>
    <tr>
      <td>Tên</td>
      <td><label>
        <input name="username" type="text" id="name" size="30" />
      </label></td>
    </tr>
    <tr>
      <td><p>Địa chỉ </p></td>
      <td><input name="address" type="text" id="address" size="50" /></td>
    </tr>
    <tr>
      <td>Số điện thoại</td>
      <td><input type="text" name="phone" id="phone" /></td>
    </tr>
    <tr>
      <td><label>
        <input type="submit" value="Save change" />
      </label></td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <p>&nbsp;</p>
</form>
</body>
</html>